package Day02;

import java.util.Scanner;

/**
 * 二维数组差分
 */

public class TwoDifference {

    public static void insert(int[][] b, int x1, int y1, int x2, int y2, int c) {
        b[x1][y1] += c;
        b[x2 + 1][y1] -= c;
        b[x1][y2 + 1] -= c;
        b[x2 + 1][y2 + 1] += c;
    }

    public static void main(String[] args) {
        int[][] a = new int[Common.N][Common.N];
        int[][] b = new int[Common.N][Common.N];
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int q = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = scanner.nextInt();
            }
        }
        // 构造差分矩阵
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                insert(b, i, j, i, j, a[i][j]);
            }
        }
        while (q != 0) {
            int x1, x2, y1, y2, c;
            x1 = scanner.nextInt();
            y1 = scanner.nextInt();
            x2 = scanner.nextInt();
            y2 = scanner.nextInt();
            c = scanner.nextInt();
            insert(b, x1, y1, x2, y2, c);
        }
        // 还原前缀和矩阵
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                b[i][j] = b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                System.out.printf("%d ",b[i][j]);
            }
            System.out.println();
        }
    }
}
